import axios from "axios";
import ProductsData from "/src/static/json/products.json";
const isProduction = process.env.NODE_ENV === "production";

export const getProducts = async () => {
  let response;
  if (isProduction) {
    response = await axios.get(
      "https://react-shopping-cart-67954.firebaseio.com/products.json"
    );
  } else {
    response = ProductsData;
  }
  const { products } = response.data || [];
  return products;
};
